using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace OpenFlashChartLib
{
    internal static class Util
    {
        public static string ToSafeString(object value)
        {
            string str;
            if (value == null)
                return "null";
            else
                str = value.ToString();

            if (str.Length == 0)
                return string.Empty;

            str = str.Replace(",", "#comma#");
            str = HttpUtility.UrlEncode(str);
            return str;
        }

        public static string ToSafeString(string value)
        {
            string str;
            if (value == null)
                return "";
            else
                str = value;

            if (str.Length == 0)
                return string.Empty;

            str = str.Replace(",", "#comma#");
            str = HttpUtility.UrlEncode(str);
            return str;
        }
    }
}
